﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace LogAnalyzeTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult dr = openFileDialog1.ShowDialog();
            if (dr == DialogResult.OK)
            {
                string src = openFileDialog1.FileName;
                string tgt = src + ".sy.csv";
                Stream infs = openFileDialog1.OpenFile();
                FileStream oufs = new FileStream(tgt, FileMode.Create);
                LogAnalyzeBase.LogAnalyzeBase.ExportViewSyncLog(infs, oufs, new TimeSpan(0, 0, 5),true);
                MessageBox.Show("Finished.");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            DialogResult dr = openFileDialog1.ShowDialog();
            if (dr == DialogResult.OK)
            {
                string src = openFileDialog1.FileName;
                string tgt = src + ".co_s.csv";
                Stream infs = openFileDialog1.OpenFile();
                string dir = Path.GetDirectoryName(src);
                string vsrc = Path.Combine(dir, "viewSnapList.xml");
                Stream vlfs = File.OpenRead(vsrc);
                FileStream oufs = new FileStream(tgt, FileMode.Create);
                LogAnalyzeBase.LogAnalyzeBase.ExportAcrossViewStrokesLog(vlfs,infs, oufs, new TimeSpan(0, 0, 5), true);
                MessageBox.Show("Finished.");
            }

        }

        private void button3_Click(object sender, EventArgs e)
        {
            DialogResult dr = openFileDialog1.ShowDialog();
            if (dr == DialogResult.OK)
            {
                string src = openFileDialog1.FileName;
                string tgt = src + ".li_c.csv";
                Stream infs = openFileDialog1.OpenFile();
                FileStream oufs = new FileStream(tgt, FileMode.Create);
                LogAnalyzeBase.LogAnalyzeBase.ExportLinearityLog(infs, oufs, new TimeSpan(0, 0, 5));
                MessageBox.Show("Finished.");
            }

        }

        private void button4_Click(object sender, EventArgs e)
        {
            DialogResult dr = openFileDialog1.ShowDialog();
            if (dr == DialogResult.OK)
            {
                string src = openFileDialog1.FileName;
                string tgt = src + ".co_s_all.csv";
                Stream infs = openFileDialog1.OpenFile();
                string dir = Path.GetDirectoryName(src);
                string vsrc = Path.Combine(dir, "viewSnapList.xml");
                Stream vlfs = File.OpenRead(vsrc);
                FileStream oufs = new FileStream(tgt, FileMode.Create);
                LogAnalyzeBase.LogAnalyzeBase.ExportAcrossViewStrokesLog(vlfs, infs, oufs, new TimeSpan(0, 0, 5), false);
                MessageBox.Show("Finished.");
            }

        }
    }
}